#include "MarkerObject.h"

void MarkerObject::Release() {
	mesh.Release();
	meshInst.Release();
}

bool MarkerObject::Initialize(LPDIRECT3DDEVICE9 pDevice) {
	if(modelFile.empty())
		modelFile = " ";

	rotationSpeed = g_MarkerRotationSpeed;

	if(!InitializeMesh(pDevice))
		return false;
	
	return true;
}

bool MarkerObject::InitializeMesh(LPDIRECT3DDEVICE9 pDevice) {
	if(modelFile != " ") {;
		if(!mesh.Load(pDevice, modelFile)) {
			SHOWERROR("mesh.Load() - Failed", __FILE__, __LINE__);
			return false;
		}
		meshInst.setMesh(&mesh);
	} else {
		PRINT("Model file name not specified, current entry: ");
		PRINT(modelFile.c_str());	NEXT_LINE;
		return false;
	}

	return true;
}

void MarkerObject::Update(float elapsedTime) {
	meshInst.rotateRel(0.0f, rotationSpeed * elapsedTime, 0.0f);
}

void MarkerObject::Render(LPDIRECT3DDEVICE9 pDevice) {
	meshInst.Render(pDevice);
}
